package cn.wolfcode.trip.base.service.impl;

import cn.wolfcode.trip.base.domain.Strategy;
import cn.wolfcode.trip.base.domain.Tag;
import cn.wolfcode.trip.base.mapper.TagMapper;
import cn.wolfcode.trip.base.service.ITagService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class TagServiceImpl implements ITagService{

    @Autowired
    private TagMapper tagMapper;

    public List<Tag> query() {
        return tagMapper.selectAll();
    }

    public void save(Tag tag, Strategy strategy) {
        Long id = strategy.getId();
        tagMapper.insert(tag);
        tagMapper.saveRelation(tag.getId(),id);
    }

    public void saveRelation(Long id, Long strategyId) {
        tagMapper.saveRelation(id,strategyId);
    }
}
